#include "Block.h"
#include "Material.h"
#include "Chunk.h"

static Block* _fake_block = NULL;

Block::Block(){
}

u8 Block::getId(){
	return id;
}

void Block::setId(u8 _id){
	id = _id;
}

u8 Block::getData(){
//	return data;
	return more & 0x0F;
}

void Block::setData(u8 _data){
//	data = _data;
	more = (more & 0xF0) | (_data & 0x0F);
}

u8 Block::getLight(){
//	return light;
	return ((more & 0xF0) >> 4) << 1;
}

void Block::setLight(u8 _light){
//	light = _light;
	more = (((_light >> 1) & 0x0F) << 4) | (more & 0x0F);
}

Block* Block::getFakeBlock(){
	if(!_fake_block){
		_fake_block = new Block();
		_fake_block->id = 0;
		_fake_block->more = 0;
	//	_fake_block->data = 0;
	//	_fake_block->light = 0;
	}
	return _fake_block;
}

Material* Block::getMaterial(){
//	return Material::FindByIdData(this->id, this->data);
	return Material::FindByIdData(this->id, this->more & 0x0F);
}
